#include <tcr.cc>

int fn()
{
	int n, ii;
	int x, y;
	Point pts[10000], r;
	scanf("%d", &n);
	if(n == 0)
		return 1;

	scanf("%d %d", &x, &y);
	r.x = x, r.y = y, r.z = 1;

	for(ii = 0; ii < n; ii++)
	{
		scanf("%d %d", &x, &y);
		pts[ii].x = x, pts[ii].y = y, pts[ii].z = 1;
	}

	printf("%d\n", poly_contains(r, pts, n) != 0);

	return 0;
}

int main()
{
	while(!fn());
	return 0;
}
